package com.demo.hjh.thread;

public class ThreadWait {
	
	
	public static void main(String[] args) {
		Object o = new Object();
		Object o2 = new Object();
		new Thread(new Run1(o)).start();
		//new Thread(new Run2(o2)).start();
		synchronized (o) {
			o.notify();
		}
//		synchronized (o2) {
//			o2.notify();
//		}
		
	}

}

class Run1 implements Runnable {
	Object o;

	public Run1(Object o) {
		this.o=0;
	}

	@Override
	public void run() {
		System.out.println("run1");
		try {
			wait();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("run1_1");

	}

}

class Run2 implements Runnable {
	Object o;

	public Run2(Object o) {
		this.o=0;
	}

	@Override
	public void run() {
		System.out.println("run2_1");
		try {
			wait();
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println("run2_2");

	}

}
